/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * 
 */
var tronsys={
    arrayToJson:function(o) { 
        var r = []; 
        if (typeof o == "string") return "\"" + o.replace(/([\'\"\\])/g, "\\$1").replace(/(\n)/g, "\\n").replace(/(\r)/g, "\\r").replace(/(\t)/g, "\\t") + "\""; 
        if (typeof o == "object") { 
            if (!o.sort) { 
                for (var i in o) 
                    r.push(i + ":" + this.arrayToJson(o[i])); 
                if (!!document.all && !/^\n?function\s*toString\(\)\s*\{\n?\s*\[native code\]\n?\s*\}\n?\s*$/.test(o.toString)) { 
                    r.push("toString:" + o.toString.toString()); 
                } 
                r = "{" + r.join() + "}"; 
            } else { 
                for (var i = 0; i < o.length; i++) { 
                    r.push(this.arrayToJson(o[i])); 
                } 
                r = "[" + r.join() + "]"; 
            } 
            return r; 
        } 
        if (o==undefined){
            return "";
        }
        return o.toString(); 
    },
    emptyUndefined:function(x){
        if (x==undefined || x=="null" || x==null){
            x="暂无";
        }
        return x;
    },
    fmoney:function (s, n)    {
        n = n > 0 && n <= 20 ? n : 2;
        s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
        var l = s.split(".")[0].split("").reverse(),
        r = s.split(".")[1];
        t = "";
        for(i = 0; i < l.length; i ++ )
        {
            t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
        }
        return t.split("").reverse().join("") + "." + r;
    },
    langBase:"chinese",
    setCookie: function (name, value)
    {
        var Days = 30 * 24 * 60 * 60 * 1000;
        var exp = new Date();
        exp.setTime(exp.getTime() + Days);
        document.cookie = name + "=" + encodeURIComponent(value) + ";expires=" + exp.toGMTString() + "; path=/";
    },
    /**
     * 读取key为name的cookies
     *
     * @param name cookie的key
     * @return cookie的值
     **/
    getCookie: function (name)
    {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg)) {
            return decodeURIComponent(arr[2]);
        } else {
            return "";
        }
    },
    //    getCookie:    function (c_name){
    //        if (document.cookie.length>0)
    //        {
    //            c_start=document.cookie.indexOf(c_name + "=");//alert(document.cookie);
    //            if (c_start!=-1)
    //            {
    //                c_start=c_start + c_name.length+1;
    //                c_end=document.cookie.indexOf(";",c_start);
    //                if (c_end==-1) c_end=document.cookie.length;
    //                var mystr=unescape(document.cookie.substring(c_start,c_end));
    //                if ((mystr[0]=="\"")&&(mystr[mystr.length-1]=="\"")) {
    //                    mystr=mystr.substring(1,mystr.length-1);
    //                }
    //                return mystr;
    //            }
    //        }
    //        return "";
    //    },
    //    setCookie:function (name,value,days) {
    //        if (days) {
    //            var date = new Date();
    //            date.setTime(date.getTime()+(days*24*60*60*1000));
    //            var expires = "; expires="+date.toGMTString();
    //        }
    //        else var expires = "";
    //        document.cookie = name+"=\""+value+"\""+expires+"; path=/";
    //    },
    dateOut:    function (format,time){
        var today=new Date();
        var day1=60*60*24*1000;
        if (time!=null && time!=undefined && time>1){
            today.setTime(time);
        }
        month=this.formatDate0(today.getMonth()+1);
        year=this.formatDate0(today.getFullYear());
        //alert(year);
        //alert(Math.ceil(year/4));
        day=this.formatDate0(today.getDate());
        if (time==-1){
            day="01";
        }
        if (time==-2){ 
            switch (today.getMonth())
            {
                case 1:
                    day="28";
                    if(year%400 ==0 || (year%100 != 0 && year%4 == 0)){
                        day="29";
                    } 
                    break;
                default :
                    day="31"; 
                    break;
                case 3:
                    day="30";
                    break;
                case 5:
                    day="30";
                    break;
                case 8:
                    day="30";
                    break;
                case 10:
                    day="30";
                    break;
            }
        }
        if (time==-3){
            month="01";
            day="01";
        }
        if (time==-4){
            month="12";
            day="31";
        }
        if (time<-4 || time==1) {            
            if (time==-5){
                time=-3;
            }
           
            //var  prevDay=today.getTime()-(60*60*24*1000*365*44);
            var  prevDay=today.getTime()-(day1*Math.abs(time));
            // alert(today.getTime()+".."+prevDay);
            today.setTime(prevDay);
            month=this.formatDate0(today.getMonth()+1);
            year=this.formatDate0(today.getFullYear());
        
            //alert(Math.ceil(year/4));
            day=this.formatDate0(today.getDate());
            hour=this.formatDate0(today.getHours());
            min=this.formatDate0(today.getMinutes());
            sec=this.formatDate0(today.getSeconds());
        //
        //+".."+today.getTime()+",,,"+dateOut(false, prevDay));
        //return this.dateOut(false, Math.abs(prevDay));
        }
        if (time==20 || time==21){            
            month=Today.getMonth();
            year=Today.getFullYear();
            if ((month-1)<0){
                month=11;                
                year=Today.getFullYear();
                year--;
            }            
            day="01";
            if (time==21){  
                var n=month;
                switch (n)
                {
                    case 2:
                        day="28";
                        if(year%400 ==0 || (year%100 != 0 && year%4 == 0)){
                            day="29";
                        } 
                        break;
                    default :
                        day="31"; 
                        break;
                    case 4:
                        day="30";
                        break;
                    case 6:
                        day="30";
                        break;
                    case 9:
                        day="30";
                        break;
                    case 11:
                        day="30";
                        break;
                }
            }
            month=this.formatDate0(month);
        }
        if (time==365 || time==366){            
            month="01";
            year=Today.getFullYear();
            year--;                      
            day="01";
            if (time==366){  
                month="12";
                day="31";
            }
        }
        //    alert(format+"..."+time);
        hour=this.formatDate0(today.getHours());
        min=this.formatDate0(today.getMinutes());
        sec=this.formatDate0(today.getSeconds());
        if (format==null){
            return year+"-"+month+"-"+day+" "+hour+":"+min+":"+sec+".0";
        }
        if (!format) {
            return year+"-"+month+"-"+day;
        }
        if (format) {
            return hour+":"+min+":"+sec+".0";
        }
    },
    formatDate:function (x, y){
        var tmx=x;        
        if (y=="true"){
            tmx=x.split(" ")[0];
        } else {
            if (x.split(":").length==3){
                tmx=x.substring(0,x.lastIndexOf(":"));
            }             
        }
        return tmx;
    },
    popDialog:function(msg,time){
        var divx=document.createElement("div");
        if (this.langBase=="chinese"){
            $(divx).attr("title","提示信息");
        } else {
            $(divx).attr("title","Alert Message");
        }
        
        $(divx).dialog({
            autoOpen: true,
            height: 168,
            width:488,
            modal: true,
            closeOnEscape: true,
            resizable: false
        });
        $(divx).html("<p style='font:14px; width:100%; margin:auto; text-align:center'>"+msg+"</p>");
        $(divx).animate({
            opacity: 0.99
        }, time, function() {
            $(divx).dialog("close");
        });
    },
    saveConfirm:function (x){
        var mxg="Sure to save?";
        var langBase=this.langBase;
        if (x==0){
            if (langBase=="chinese"){
                mxg="确定储存吗？";
            }
            if (langBase=="thai"){
                mxg="ตรวจสอบเพื่อบันทึก?";
            }
        }
        if (x==1){
            mxg="Sure to delete?";
            if (langBase=="chinese"){
                mxg="确定删除吗？";
            }
            if (langBase=="thai"){
                mxg="แน่นอนว่าจะลบ?";
            }
        }
        if (x==2){
            mxg="Page will be reset, any unsaved work may lost. sure to proceed?";
            if (langBase=="chinese"){
                mxg="页面重置，任何未完成的工作会丢失。 确定执行吗？";
            }
            if (langBase=="thai"){
                mxg="หน้าจะถูกรีเซ็ต, ตรวจสอบเพื่อดำเนินการต่อไป?";
            }
        }
        if (x==3){
            mxg="Search will take time, sure to proceed?";
            if (langBase=="chinese"){
                mxg="搜索时间可能会久，确定执行吗？";
            }
            if (langBase=="thai"){
                mxg="ค้นหาจะใช้เวลาตรวจสอบเพื่อดำเนินการต่อไป?";
            }
        }
        if (x==4){
            mxg="Continue to Reset?";
            if (langBase=="chinese"){
                mxg="确定执行重置吗？";
            }
            if (langBase=="thai"){
                mxg="Continue to Reset?";
            }
        }
        if (x==5){
            mxg="Start to retrieve images?";
            if (langBase=="chinese"){
                mxg="确定执行下载图片吗？";
            }
            if (langBase=="thai"){
                mxg="Start to retrieve images?";
            }
        }
        if (x==6){
            mxg="Sure to print?";
            if (langBase=="chinese"){
                mxg="确定打印吗？";
            }
            if (langBase=="thai"){
                mxg="Sure to print?";
            }
        }
        if (x==7){
            mxg="Start Voice Recording?";
            if (langBase=="chinese"){
                mxg="确定录音吗？";
            }
            if (langBase=="thai"){
                mxg="Start Voice Recording?";
            }
        }
        if (x==8){
            mxg="This will cause a new report, Ok to proceed?";
            if (langBase=="chinese"){
                mxg="这样会生成新的报告，确定继续吗？";
            }
            if (langBase=="thai"){
                mxg="This will cause a new report, Ok to proceed?";
            }                     
        }
        if (x==9){
            mxg="Proceed to upload files?";
            if (langBase=="chinese"){
                mxg="确定执行上载文件吗？";
            }
            if (langBase=="thai"){
                mxg="Proceed to upload files?";
            }
        }
        if (x==10){
            mxg="Are you sure to proceed?";
            if (langBase=="chinese"){
                mxg="确定执行吗？";
            }
            if (langBase=="thai"){
                mxg="Are you sure to proceed?";
            }
        }
        if (x==11){
            mxg="Are you sure to log off?";
            if (langBase=="chinese"){
                mxg="确定退出吗?";
            }
            if (langBase=="thai"){
                mxg="คุณแน่ใจที่จะออกจากระบบ?";
            }
        }
        if (x==12){
            mxg="Did you insert the media yet?";
            if (langBase=="chinese"){
                mxg="光盘已放进光驱了吗?";
            }
            if (langBase=="thai"){
                mxg="คุณใส่สื่อยัง?";
            }
        }
        if (x==13){
            mxg="Create new download folder?";
            if (langBase=="chinese"){
                mxg="建立全新下载文件夹吗?";
            }
            if (langBase=="thai"){
                mxg="Create new download folder?";
            }
        }
        if (x==14){
            mxg="Document is modified, need to save?";
            if (langBase=="chinese"){
                mxg="原稿已被修改，需要储存吗？";
            }
            if (langBase=="thai"){
                mxg="Document is modified, need to save?";
            }
        }
        if (x==15){
            mxg="Sure to sent?";
            if (langBase=="chinese"){
                mxg="确定发送吗？";
            }
            if (langBase=="thai"){
                mxg="确定发送吗?";
            }
        }
        if (confirm(mxg)){
            ctrldown=false;
            return true;
        } else {
            return false;
        }
    },
    dataSaved:function (x,y){
        var mxg="Saved!";
        var langBase=this.langBase;
        console.log(langBase);
        if (x==0){
            if (langBase=="chinese"){
                mxg="已保存！";
            }
            if (langBase=="thai"){
                mxg="Saved!";
            }
        }
        if (x==1){
            mxg="Item removed!";
            if (langBase=="chinese"){
                mxg="项目删除！";
            }
            if (langBase=="thai"){
                mxg="รายการออก!";
            }
    
        }
        if (x==2){
            mxg="Procesing!";
            if (langBase=="chinese"){
                mxg="执行中！";
            }
            if (langBase=="thai"){
                mxg="การประมวลผล!";
            }
        }
        if (x==3){
            mxg="Information Sent!";
            if (langBase=="chinese"){
                mxg="已发送！";
            }
            if (langBase=="thai"){
                mxg="";
            }
        }
        if (x==4){
            mxg="No Record Return!";
            if (langBase=="chinese"){
                mxg="无数据！";
            }
            if (langBase=="thai"){
                mxg="";
            }
        }
        if (x==5){
            mxg="Missing required field, unable to process!";
            if (langBase=="chinese"){
                mxg="缺小数据，无法处理！";
            }
            if (langBase=="thai"){
                mxg="";
            }
        }
        if (x==6){
            mxg="Setting Reload!";
            if (langBase=="chinese"){
                mxg="设定已还原！";
            }
            if (langBase=="thai"){
                mxg="การตั้งค่าใหม่!";
            }
        }
        if (x==7){
            mxg="Problem to save!";
            if (langBase=="chinese"){
                mxg="有问题！保存失败。";
            }
            if (langBase=="thai"){
                mxg="ปัญหาที่จะบันทึก!";
            }
        }  
        if (x==8){
            mxg="Data Updated!";
            if (langBase=="chinese"){
                mxg="数据，处理完毕。";
            }
            if (langBase=="thai"){
                mxg="Data Updated!";
            }
        } 
        if (x==9){
            mxg="Athena did not have the study ready yet. Please wait, images are now transfering.";
            if (langBase=="chinese"){
                mxg="工作站未有数据，请稍等，正在发送。";
            }
            if (langBase=="thai"){
                mxg="Osirix did not have the study ready yet. Please wait, images are now transfering.";
            }
        }
        if (x==10){
            mxg="Workstation not online!";
            if (langBase=="chinese"){
                mxg="工作站不在线，请检测！";
            }
            if (langBase=="thai"){
                mxg="Workstation not online";
            }
        }
        if (x==11){
            mxg="ORU not created!";
            if (langBase=="chinese"){
                mxg="HIS 报告无法建立 ORU！";
            }
            if (langBase=="thai"){
                mxg="ORU not created!";
            }
        }
        if (y && y!="null" && y!="undefined"){
            tronsys.popDialog(mxg,y);
        } else
            tronsys.popDialog(mxg,800);
    },
    getBrowser:function(x){
        var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
        var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
        var is_safari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
        if (is_chrome){
            is_safari=false;
        }
        if (x=="is_chrome"){
            return is_chrome;
        } else if (x=="is_firefox"){
            return is_firefox;
        } else if (x=="is_safari"){
            return is_safari;
        } else if (x=="is_IE"){
            return (!is_chrome && !is_firefox && !is_safari);
        }  
    },
    GenderList:function(){
        var gensrc=[];
        if (this.langBase=="chinese") {    
            gensrc= [{
                label:"男性",
                data:"M"
            },{
                label:"女性",
                data:"F"
            },{
                label:"不确定",
                data:"NA"
            }];
        } else if (this.langBase=="thai") {    
            gensrc= [{
                label:"เพศชาย",
                data:"M"
            },{
                label:"เพศหญิง",
                data:"F"
            },{
                label:"ไม่แน่ใจ",
                data:"NA"
            }];
        } else {    
            gensrc= [{
                label:"Male",
                data:"M"
            },{
                label:"Female",
                data:"F"
            },{
                label:"N/A",
                data:"NA"
            }];
        }
        return gensrc;
    },
    MaritalStatusList:function(){
        var MaritalStatus=[];
        if (this.langBase=="chinese") {    
            MaritalStatus= [{
                label:"单身",
                data:"单身"
            },{
                label:"已婚",
                data:"已婚"
            },{
                label:"分居",
                data:"分居"
            }
            ,{
                label:"离婚",
                data:"离婚"
            },{
                label:"孤寡",
                data:"孤寡"
            },{
                label:"不回答",
                data:"不回答"
            }];
        } else if (this.langBase=="thai") {    
            MaritalStatus= [{
                label:"เดียว",
                data:"เดียว"
            },{
                label:"แต่งงาน",
                data:"แต่งงาน"
            },{
                label:"แยกออกจากกัน",
                data:"แยกออกจากกัน"
            }
            ,{
                label:"หย่าร้าง",
                data:"หย่าร้าง"
            },{
                label:"เป็นม่าย",
                data:"เป็นม่าย"
            },{
                label:"จะไม่ตอบ",
                data:"จะไม่ตอบ"
            }];
        } else {    
            MaritalStatus= [{
                label:"Single",
                data:"Single"
            },{
                label:"Married",
                data:"Married"
            },{
                label:"Separated",
                data:"Separated"
            }
            ,{
                label:"Divorced",
                data:"Divorced"
            },{
                label:"Widowed",
                data:"Widowed"
            },{
                label:"Not to Answer",
                data:"Not to Answer"
            }];
        }
        return MaritalStatus;
    },
    EmploymentStatusList:function(){
        var EmploymentStatus=[];
        if (this.langBase=="chinese") {    
            EmploymentStatus= [{
                label:"全职",
                data:"全职"
            },{
                label:"兼职",
                data:"兼职"
            },{
                label:"自雇",
                data:"自雇"
            }
            ,{
                label:"学生",
                data:"学生"
            },{
                label:"失业",
                data:"失业"
            },{
                label:"退休",
                data:"退休"
            },{
                label:"不回答",
                data:"不回答"
            }];
        } else if (this.langBase=="thai") {    
            EmploymentStatus= [{
                label:"เต็มเวลา",
                data:"เต็มเวลา"
            },{
                label:"Part-Time",
                data:"Part-Time"
            },{
                label:"รับจ้างตนเอง",
                data:"รับจ้างตนเอง"
            }
            ,{
                label:"นักเรียน",
                data:"นักเรียน"
            },{
                label:"ว่างงาน",
                data:"ว่างงาน"
            },{
                label:"เกษียณ",
                data:"เกษียณ"
            },{
                label:"จะไม่ตอบ",
                data:"จะไม่ตอบ"
            }];
        } else {    
            EmploymentStatus= [{
                label:"Full-Time",
                data:"Full-Time"
            },{
                label:"Part-Time",
                data:"Part-Time"
            },{
                label:"Self-Employed",
                data:"Self-Employed"
            }
            ,{
                label:"Student",
                data:"Student"
            },{
                label:"Unemployed",
                data:"Unemployed"
            },{
                label:"Retired",
                data:"Retired"
            },{
                label:"Not to Answer",
                data:"Not to Answer"
            }];
        } 
        return EmploymentStatus;
    },
    SalStatusList:function(){
        var SalStatus=[];
        if (this.langBase=="chinese") {    
            SalStatus= [{
                label:"先生",
                data:"先生"
            },{
                label:"夫人",
                data:"夫人"
            },{
                label:"女士",
                data:"女士"
            },{
                label:"小姐",
                data:"小姐"
            }
            ,{
                label:"博士",
                data:"博士"
            },{
                label:"医师",
                data:"医师"
            }];
        } else if (this.langBase=="thai") {    
            SalStatus= [{
                label:"Mr.",
                data:"Mr."
            },{
                label:"Mrs.",
                data:"Mrs."
            },{
                label:"Ms.",
                data:"Ms."
            },{
                label:"Miss.",
                data:"Miss."
            }
            ,{
                label:"Dr.",
                data:"Dr."
            },{
                label:"M.D.",
                data:"M.D."
            }];
        } else {    
            SalStatus= [{
                label:"Mr.",
                data:"Mr."
            },{
                label:"Mrs.",
                data:"Mrs."
            },{
                label:"Ms.",
                data:"Ms."
            },{
                label:"Miss.",
                data:"Miss."
            }
            ,{
                label:"Dr.",
                data:"Dr."
            },{
                label:"M.D.",
                data:"M.D."
            }];
        }
        return SalStatus;
    },
    QueryString : function(item){
        var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)","i"));
        return svalue ? svalue[1] : svalue;
    },
    Mobile:function(){
        var mobile=false;
        if( navigator.userAgent.match(/Android/i)
            || navigator.userAgent.match(/webOS/i)
            || navigator.userAgent.match(/iPhone/i)
            || navigator.userAgent.match(/iPad/i)
            || navigator.userAgent.match(/iPod/i)
            || navigator.userAgent.match(/BlackBerry/i)
            ){
            mobile=true;
        }
        return mobile;
    },
    OSName:function(){
        var OSName="Unknown OS";
        if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
        if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
        if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
        if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
        return OSName;        
    },
    defLang:function(){
        var chkLang=(navigator.language ? navigator.language
            : navigator.userLanguage || "");
    
        if (chkLang!=""){
            if (chkLang.split("-")[0]=="en"){
                this.langBase="english";
            }
            if (chkLang.split("-")[0]=="zh"){
                this.langBase="chinese";
            }
            if (chkLang.split("-")[0]=="th"){
                this.langBase="thai";
            }
        }
    },
    updateLang:function (){  
        var x=this.langBase;
        $("label, button, div,option,title,td,a").each(function(){
            if ($(this).text()==$(this).html() && $(this).attr(x)){
                $(this).text($(this).attr(x)); 
            }            
        });
        $("img, .langTitle, input").each(function(){
            if ( $(this).attr(x)){
                $(this).attr("title",$(this).attr(x)); 
            }            
        });
    },
    blinkStop:function (x,y){
        for (bb in this.blinkObj){
            //console.log($(x).text()+".."+$(this.blinkObj[bb]).text());
            if ($(this.blinkObj[bb]).is(x)){
                //console.log(this.blinkObj.length);
                this.blinkObj.splice(bb,1);
                //console.log(this.blinkObj.length);
                if (y){
                    $(x).css("color",y);
                }
                break;
            }
        }
       
    },
    newBlinkObj:function(x,y){
        var targeto="";
        for (bb in this.blinkObj){
            if (this.blinkObj[bb]==x){
                targeto=this.blinkObj[bb];
                break;
            }
        }
        if (targeto==""){
            this.blinkObj.push(x);
        }
        
        if (y){
            $(x).css("color",y);
        }
        this.blinkStart(x);
    },
    blinkStart:function (x){
        var targeto="";
        for (bb in this.blinkObj){
            if (this.blinkObj[bb]==x){
                targeto=this.blinkObj[bb];
                break;
            }
        }
        console.log("targeto="+targeto);
        if (targeto!=""){
            $(targeto).animate({
                opacity:0.18
            }, 1000,function(){
                $(this).animate({
                    opacity:1
                },1000,function(){
                    tronsys.blinkStart(targeto);
                });
            });
            
        }
    //$(x).fadeTo(100,0).delay(100).fadeTo(100,1, blink(this));
    },
    blinkObj:[],
    blinkOnce:function(o){
        $(o).show().animate({
            opacity:0
        },300,function(){
            $(this).animate({
                opacity:1
            },1000);
        });
    },
    WindowSize:    function (inSize) {
        var myWidth = 0, myHeight = 0;
        if( typeof( window.innerWidth ) == 'number' ) {
            //Non-IE
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
            
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
        }
        inSize=(inSize=="w")?myWidth:inSize;
        inSize=(inSize=="h")?myHeight:inSize;
        return inSize;
    },
    selectColor:"",
    initColor:function(x,y){
        var link=document.createElement("link");
        
        $(link).attr("rel","stylesheet");
        $(link).attr("type","text/css");
        $(link).attr("href",x);
        $("head").append(link);
        
        var script=document.createElement("script");
        
        $(script).attr("type","text/javascript");
        $(script).attr("src",y);
        
        $("head").append(script);
    //<link href='<%=proj_root%>/css/master.css' rel='stylesheet' type='text/css' />
    },
    colorDialog:function(x){ //bodyC required to receive dialog
        var div=document.createElement("div");
        if (this.langBase=="chinese"){
            $(div).attr("title","调色板");
        }
        else {
            $(div).attr("title","Color Dialog");
        }
        
        $(div).load("../color/index.html",function(d){
            $(this).dialog({
                autoOpen: true,
                height: 298,
                width:238,
                modal: true,
                closeOnEscape: true,
                resizable: false,
                close:function(event,ui){
                    if (x){
                        eval(x);
                    }
                
                }
            }); 
        });
    },
    formatDate0:function (str){
        if (str<10) {
            str="0"+str;
        }
        return str;
    },
    replaceCarriageReturn:function (textarea,replaceWith)
    { 
        textarea = escape(textarea);
        //encode all characters in text area
        //to find carriage return character
        //for(i=0; i < textarea.length; i++)
        //{ 
        //loop through string, replacing carriage return 
        //encoding with HTML break tag
        if(textarea.indexOf("%0D%0A") > -1)
        { 
            //Windows encodes returns as \r\n hex
            textarea=textarea.replace("%0D%0A",replaceWith);
        }
        else if(textarea.indexOf("%0A") > -1)
        { 
            //Unix encodes returns as \n hex
            textarea=textarea.replace("%0A",replaceWith);
        }
        else if(textarea.indexOf("%0D") > -1)
        { 
            //Macintosh encodes returns as \r hex
            textarea=textarea.replace("%0D",replaceWith);
        }
        //}
        return unescape(textarea);
    //decode all characters in text area back
    },
    showResponse:function(x){
        $(x).animate({
            opacity:0
        },500,function(){
            $(this).css({
                opacity:1
            });
        });
    },
    generateMixed:function(n){
        var res = "";
        var randomchars = ['0','1','2','3','4','5','6','7','8','9'];
        //,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
        for(var i = 0; i < n ; i ++) {
            var id = Math.ceil(Math.random()*9);
           // alert(id);
            res += randomchars[id];
        }
        return res;
    }
    
}

tronsys.defLang();
//tronsys.initColor("/hospital1/color/farbtastic.css","/hospital1/color/farbtastic.js");
function reloadFrame(x){
    //alert(location+".."+x+".."+$("#"+x).attr("src"));
    $("#"+x).attr("src",$("#"+x).attr("src"));
}
